Adding support for @implements. - #36292
Conversation
|
Yes I would like to try it out. I will be able to do so next week when I am back in the office. |
|
To be able to debug, I would need a bot-pack build that I can try out. Let me know when you have one available 😄 |
|
Tim van der Lippe (@TimvdLippe) I unfortunately can't summon the TS bot .. let me try something, <clears-throat /> <incantation-voice> |
|
Sure! |
|
Heya Orta Therox (@orta), I've started to run the tarball bundle task on this PR at 5a7fdd5. You can monitor the build here. It should now contribute to this PR's status checks. |
|
Hey Orta Therox (@orta), I've packed this into an installable tgz. You can install it for testing by referencing it in your and then running There is also a playground for this build. |
|
Titian Cernicova-Dragomir (@dragomirtitian) re your questions:
I will look at the code now. I'm a linguist, so I prefer the traditional 3 invocations. Like this: NoamChomsky NoamChomsky NoamChomsky |
Nathan Shively-Sanders (sandersn)
left a comment
There was a problem hiding this comment.
Looks good so far. I have a couple of initial suggestions.
As for tests, don't forget fourslash tests -- I think we suggest completions based on implements so the same thing should work for @implements.
|
I can confirm that the updated build is catching issues like missing overrides. That said, we are hitting a couple of other issues with TypeScript (#19983) which makes it hard for us to fully test all of its internals. My understanding thus far is that this change is WAI. One improvement that would be great is that methods with Thank you for doing the work and for the quick implementation! |
|
Tim van der Lippe (@TimvdLippe) The scope of this was specifically defined as support for If not I think the only workaround for now would be to |
|
Titian Cernicova-Dragomir (@dragomirtitian) I'd like to keep support for |
|
Nathan Shively-Sanders (@sandersn) Given our extensive use of I am okay with punting that to a different PR though. |
|
Looking at the example in the jsdoc documentation (excerpted below), I note that throwing in the interface body satisfies Typescript because throwing causes the function to return /**
* @interface
*/
function Color() {}
/**
* @returns {Array<number>} An array containing the red, green, and blue values, in that order.
*/
Color.prototype.rgb = function() {
throw new Error('not implemented');
};Does that work with Closure? |
|
Nathan Shively-Sanders (@sandersn) I just checked and the following does indeed compile in both Closure and TS (with this patch): /**
* @interface
*/
export class EventTarget {
/**
* @param {symbol} eventType
* @param {function(!Common.Event)} listener
* @param {!Object=} thisObject
* @return {!Common.EventTarget.EventDescriptor}
*/
addEventListener(eventType, listener, thisObject) {
throw new Error(`Not implemented`);
}
} |
|
Nathan Shively-Sanders (@sandersn) I fixed the code review issues. I added a test for multiple interfaces. I ran into the following issues;
Also sorry for the delay, it's been a hectic week at work. |
|
There was a problem hiding this comment.
I think this is ready to go, at least as far as I can tell. Titian Cernicova-Dragomir (@dragomirtitian) do you want to take it off Draft status?
(Edit: When the minor test suggestions are done.)
|
TypeScript Bot (@typescript-bot) user test this |
|
Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized community code test suite on this PR at d7839fe. You can monitor the build here. It should now contribute to this PR's status checks. |
|
ha ha oh no now user tests are broken because of the new octokit. |
|
(fix is at #36915; I'll merge it after I see that it can post a user test PR) |
|
Titian Cernicova-Dragomir (@dragomirtitian) can you merge from master and then I'll run the user tests? |
|
Nathan Shively-Sanders (@sandersn) Yes, I'll merge from master. First I want to fix the declaration emit for |
|
Nathan Shively-Sanders (@sandersn) I merged master, and fixed declaration emit. You should have a look at the emit fixes. |
|
TypeScript Bot (@typescript-bot) user test this |
|
Heya Nathan Shively-Sanders (@sandersn), I've started to run the parallelized community code test suite on this PR at cedc792. You can monitor the build here. It should now contribute to this PR's status checks. |
|
Nathan Shively-Sanders (@sandersn) The user tests seem to have failed again :( |
|
I think this will be ready once you get rid of the unneeded checks. |
|
Nathan Shively-Sanders (@sandersn) Ok, I think we are good to go! |
|
Titian Cernicova-Dragomir (@dragomirtitian) Thanks for your hard work on this one! |
Fixes #35629
Open issues:
Nathan Shively-Sanders (@sandersn) For 1 I would suppress these errors for JS. For 2, do you think it is worth showing the fix? Also maybe we could have a typescript-bot pack of this so Tim van der Lippe (@TimvdLippe) can maybe give it a try.
One issue, unrelated to
@implementsnecessarily, is that method in the classes used as interfaces in Tim van der Lippe (@TimvdLippe) example don't have any return statement, so any return type will cause an error. Support for@abstractwas taken out of the scope of #35629, but maybe adding support for@abstractcould be useful to suppress these errors. Using@ts-ignoremight also be a simpler workaround.